﻿<%@ Page Language="C#" AutoEventWireup="true" CodeFile="register.aspx.cs" Inherits="cn_register" %>


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
    <title>会员注册，<%=(new Web.Old_App_Code.BasicSet()).TitleBind() %></title>
    <meta name="Keywords" content="<%=(new Web.Old_App_Code.BasicSet()).KeywordBind() %>" />
    <meta name="Description" content="<%=(new Web.Old_App_Code.BasicSet()).DescriptionBind() %>" />
    <script type="text/javascript" src="<%=(new Web.Old_App_Code.TemplateLoad()).TemplateCssLoad() %>js/jquery-1.6.2.min.js"></script>

    <link href="<%=(new Web.Old_App_Code.TemplateLoad()).TemplateCssLoad() %>css/public.css" type="text/css" rel="stylesheet" />
    <link href="<%=(new Web.Old_App_Code.TemplateLoad()).TemplateCssLoad() %>css/member.css" type="text/css" rel="stylesheet" />
    <!--登陆注册 弹出窗口-->
    <style type="text/css" media="all">
        @import "<%=(new Web.Old_App_Code.TemplateLoad()).TemplateCssLoad() %>js/login/thickbox.css";
    </style>

    <script src="<%=(new Web.Old_App_Code.TemplateLoad()).TemplateCssLoad() %>js/login/thickbox.js" type="text/javascript"></script>
    
     <link href="<%=(new Web.Old_App_Code.TemplateLoad()).TemplateCssLoad() %>art_dialog/skins/idialog.css" rel="stylesheet" />

    <script type="text/javascript" src="<%=(new Web.Old_App_Code.TemplateLoad()).TemplateCssLoad() %>art_dialog/artDialog.js"></script>

    <script type="text/javascript" src="<%=(new Web.Old_App_Code.TemplateLoad()).TemplateCssLoad() %>art_dialog/plugins/iframeTools.source.js"></script>

    <script type="text/javascript" src="<%=(new Web.Old_App_Code.TemplateLoad()).TemplateCssLoad() %>js/art_dialog.js"></script>

</head>

<script type="text/javascript">
    $(function () {
        $("#txtUserName").blur(function () {
            if ($("#txtUserName").val() == "") {
                $("#spUserName").html("<img src=\"<%=(new Web.Old_App_Code.TemplateLoad()).TemplateCssLoad() %>images/wrong.gif\" />请输入用户名！");
            }
            else {
                if ($("#txtUserName").val().length < 4 || $("#txtUserName").val().length > 16)
                    $("#spUserName").html("<img src=\"<%=(new Web.Old_App_Code.TemplateLoad()).TemplateCssLoad() %>images/wrong.gif\" />用户名长度不符！");
                else $("#spUserName").html("<img src=\"<%=(new Web.Old_App_Code.TemplateLoad()).TemplateCssLoad() %>images/right.gif\"/>");
            }
            return false;
        });
        $("#txtUserPwd").blur(function () {
            if ($("#txtUserPwd").val() == "") $("#spPwd").html("<img src=\"<%=(new Web.Old_App_Code.TemplateLoad()).TemplateCssLoad() %>images/wrong.gif\" />请输入密码！");
            else {
                if ($("#txtUserPwd").val().length < 6 || $("#txtUserPwd").val().length > 16)
                    $("#spPwd").html("<img src=\"<%=(new Web.Old_App_Code.TemplateLoad()).TemplateCssLoad() %>images/wrong.gif\" />密码长度不符，必须在6-16个字符之间！");
                else $("#spPwd").html("<img src=\"<%=(new Web.Old_App_Code.TemplateLoad()).TemplateCssLoad() %>images/right.gif\"/>");
            }
            return false;
        });
        $("#txtAgainPwd").blur(function () {
            if ($("#txtAgainPwd").val() == "") $("#spAgPwd").html("<img src=\"<%=(new Web.Old_App_Code.TemplateLoad()).TemplateCssLoad() %>images/wrong.gif\" />请输入确认密码！");
            else {
                if ($("#txtAgainPwd").val() != $("#txtUserPwd").val())
                    $("#spAgPwd").html("<img src=\"<%=(new Web.Old_App_Code.TemplateLoad()).TemplateCssLoad() %>images/wrong.gif\" />确认密码不一致！");
                else $("#spAgPwd").html("<img src=\"<%=(new Web.Old_App_Code.TemplateLoad()).TemplateCssLoad() %>images/right.gif\"/>");
            }
            return false;
        });
        $("#txtEmail").blur(function () {
            if ($("#txtEmail").val() == "") $("#spEmail").html("<img src=\"<%=(new Web.Old_App_Code.TemplateLoad()).TemplateCssLoad() %>images/wrong.gif\" />请输入电子邮箱！");
            else {
                if ($("#txtEmail").val().match(/^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/) == null)
                    $("#spEmail").html("<img src=\"<%=(new Web.Old_App_Code.TemplateLoad()).TemplateCssLoad() %>images/wrong.gif\" />电子邮箱格式不符！");
                else $("#spEmail").html("<img src=\"<%=(new Web.Old_App_Code.TemplateLoad()).TemplateCssLoad() %>images/right.gif\"/>");
            }
            return false;
        });
        $("#txtCode").blur(function () {
            if ($("#txtCode").val() == "") $("#spCode").html("<img src=\"<%=(new Web.Old_App_Code.TemplateLoad()).TemplateCssLoad() %>images/wrong.gif\" />请输入验证码！");
            else $("#spCode").html("<img src=\"<%=(new Web.Old_App_Code.TemplateLoad()).TemplateCssLoad() %>images/right.gif\"/>");
            return false;
        });
        $("#cbServer").blur(function () {
            if (!$("#cbServer").attr("checked")) art.dialog.tips("请阅读并同意《商城服务条款》！", 1.5);
            return false;
        });

        $("#btnRegisterSubmit").click(function () {
            ///用户名
            if ($("#txtUserName").val() == "") {
                $("#txtUserName").select();
                $("#spUserName").html("<img src=\"<%=(new Web.Old_App_Code.TemplateLoad()).TemplateCssLoad() %>images/wrong.gif\" />请输入用户名！");
                return false;
            }
            else {
                if ($("#txtUserName").val().length < 4 || $("#txtUserName").val().length > 16) {
                    $("#txtUserName").select();
                    $("#spUserName").html("<img src=\"<%=(new Web.Old_App_Code.TemplateLoad()).TemplateCssLoad() %>images/wrong.gif\" />用户名长度不符！");
                    return false;
                } else $("#spUserName").html("<img src=\"<%=(new Web.Old_App_Code.TemplateLoad()).TemplateCssLoad() %>images/right.gif\"/>");
            }
            ///用户密码
            if ($("#txtUserPwd").val() == "") {
                $("#txtUserPwd").select();
                $("#spPwd").html("<img src=\"<%=(new Web.Old_App_Code.TemplateLoad()).TemplateCssLoad() %>images/wrong.gif\" />请输入密码！");
                return false;
            } else {
                if ($("#txtUserPwd").val().length < 6 || $("#txtUserPwd").val().length > 16) {
                    $("#txtUserPwd").select();
                    $("#spPwd").html("<img src=\"<%=(new Web.Old_App_Code.TemplateLoad()).TemplateCssLoad() %>images/wrong.gif\" />密码长度不符，必须在6-16个字符之间！");
                    return false;
                } else $("#spPwd").html("<img src=\"<%=(new Web.Old_App_Code.TemplateLoad()).TemplateCssLoad() %>images/right.gif\"/>");
            }
            ///确认密码
            if ($("#txtAgainPwd").val() == "") {
                $("#txtAgainPwd").select();
                $("#spAgPwd").html("<img src=\"<%=(new Web.Old_App_Code.TemplateLoad()).TemplateCssLoad() %>images/wrong.gif\" />请输入确认密码！");
                return false;
            } else {
                if ($("#txtAgainPwd").val() != $("#txtUserPwd").val()) {
                    $("#txtAgainPwd").select();
                    $("#spAgPwd").html("<img src=\"<%=(new Web.Old_App_Code.TemplateLoad()).TemplateCssLoad() %>images/wrong.gif\" />确认密码不一致！");
                    return false;
                } else $("#spAgPwd").html("<img src=\"<%=(new Web.Old_App_Code.TemplateLoad()).TemplateCssLoad() %>images/right.gif\"/>");
            }
            ///Email
            if ($("#txtEmail").val() == "") {
                $("#txtEmail").select();
                $("#spEmail").html("<img src=\"<%=(new Web.Old_App_Code.TemplateLoad()).TemplateCssLoad() %>images/wrong.gif\" />请输入电子邮箱！");
                return false;
            } else {
                if ($("#txtEmail").val().match(/^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/) == null) {
                    $("#txtEmail").select();
                    $("#spEmail").html("<img src=\"<%=(new Web.Old_App_Code.TemplateLoad()).TemplateCssLoad() %>images/wrong.gif\" />电子邮箱格式不符！");
                    return false;
                } else $("#spEmail").html("<img src=\"<%=(new Web.Old_App_Code.TemplateLoad()).TemplateCssLoad() %>images/right.gif\"/>");
            }
            if ($("#txtCode").val() == "") {
                $("#txtCode").select();
                $("#spCode").html("<img src=\"<%=(new Web.Old_App_Code.TemplateLoad()).TemplateCssLoad() %>images/wrong.gif\" />请输入验证码！");
                return false;
            } else $("#spCode").html("<img src=\"<%=(new Web.Old_App_Code.TemplateLoad()).TemplateCssLoad() %>images/right.gif\"/>");
            if (!$("#cbServer").attr("checked")) {
                $("#cbServer").focus();
                art.dialog.tips("请阅读并同意《商城服务条款》！", 1.5);
                return false;
            }
            $.ajax({
                type: "POST",
                url: "register.ashx",
                data: "userName=" + escape($("#txtUserName").val()) + "&userPwd=" + escape($("#txtUserPwd").val()) + "&email=" + escape($("#txtEmail").val()) + "&code=" + escape($("#txtCode").val()),
                success: function (msg) {
                    if (msg == "0") {
                        $("#txtCode").select();
                        $("#spCode").html("<img src=\"<%=(new Web.Old_App_Code.TemplateLoad()).TemplateCssLoad() %>images/wrong.gif\" />验证码错误！");
                        $("#spUserName").html("<img src=\"<%=(new Web.Old_App_Code.TemplateLoad()).TemplateCssLoad() %>images/right.gif\"/>");
                        $("#imgCheckCode").attr("src", "/code.aspx?a=" + Math.random() + "&t=register");
                    }
                    else if (msg == "1") {
                        $("#txtUserName").select();
                        $("#spUserName").html("<img src=\"<%=(new Web.Old_App_Code.TemplateLoad()).TemplateCssLoad() %>images/wrong.gif\" />用户名已存在！");
                        $("#spCode").html("<img src=\"<%=(new Web.Old_App_Code.TemplateLoad()).TemplateCssLoad() %>images/right.gif\"/>");
                    }
                    else if (msg == "2") {
                        $("#imgCheckCode").attr("src", "/code.aspx?a=" + Math.random());
                        art.dialog.tips("很抱歉，注册失败！", 1.5);
                    }
                    else {
                        art.dialog.tips("恭喜您，注册成功！", 1.5);
                        if (parent.location.href.substring(parent.location.href.lastIndexOf("/") + 1) == "shopping_cart.html") {
                            setTimeout("parent.location.reload()", 2000);
                        }
                        else {
                            parent.$("#puser").html(msg);
                            setTimeout("parent.TB_remove()", 2000);
                        }
                    }
                }
            });
            return false;
        });
    });
</script>

<body class="login">
    <div id="register">
        <h2>
            <strong>注册新用户</strong></h2>
        <form id="formRegister" action="/register.ashx" defaultbutton="btnRegisterSubmit">
            <p>
                <label for="txtUserName">
                    用户名</label><input id="txtUserName" type="text" /><span id="spUserName">*4～16个字符,包括数字、英文字母、下划线</span></p>

            <p>
                <label for="txtUserPwd">
                    用户密码</label><input id="txtUserPwd" type="password" /><span id="spPwd">*6～16个字符,包括数字、英文字母、任意字符</span></p>
            <p>
                <label for="txtAgainPwd">
                    确认密码</label><input id="txtAgainPwd" type="password" /><span id="spAgPwd">*</span></p>
            <p>
                <label for="txtEmail">
                    电子邮箱</label><input id="txtEmail" type="text" /><span id="spEmail">*</span></p>
            <p>
                <label for="txtCode">
                    验证码</label><input id="txtCode" type="text" maxlength="4" class="txtCode" autocomplete="off" /><img id="imgCheckCode"
                        src="/code.aspx?t=register" alt="看不清楚,换一张" onclick="this.src = '/code.aspx?a=' + Math.random();+'&t=register'"
                        class="imgCode" /><span id="spCode">*</span></p>
            <input id="btnRegisterSubmit" class="submit" type="submit" value="完成注册" />
            <input id="cbServer" type="checkbox" value="同意" />&nbsp;已阅读并同意<a href="terms_of_service.html?TB_iframe=true&height=310&width=610"
                title="服务条款" class="thickbox">《商城服务条款》</a>
        </form>
    </div>
</body>
</html>
